home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / include / incl98.zoo / stdarg.h < prev    next >
C/C++ Source or Header  |  1993-07-10  |  2KB  |  66 lines

  1. /*
  2.  * STDARG.H
  3.  */
  4.  
  5. #ifndef _STDARG_H
  6. #ifndef va_start    /* in case of varargs being included */
  7. #define    _STDARG_H
  8.  
  9. #ifndef _COMPILER_H
  10. #include <compiler.h>
  11. #endif
  12.  
  13. #ifdef __GNUC__
  14.  
  15. /* Define __gnuc_va_list.  */
  16.  
  17. #ifndef __GNUC_VA_LIST
  18. #define __GNUC_VA_LIST
  19. typedef void *__gnuc_va_list;
  20. #endif
  21.  
  22. /* Amount of space required in an argument list for an arg of type TYPE.
  23.    TYPE may alternatively be an expression whose type is used.  */
  24.  
  25. #define __va_rounded_size(TYPE)  \
  26.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  27.  
  28. #define va_start(AP, LASTARG)                         \
  29.  (AP = ((__gnuc_va_list) __builtin_next_arg ()))
  30.  
  31. #define va_end(AP)
  32.  
  33. /* We cast to void * and then to TYPE * because this avoids
  34.    a warning about increasing the alignment requirement.  */
  35. #define va_arg(AP, TYPE)                                                \
  36.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  37.   *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < sizeof (int)    \
  38.                      ? sizeof (TYPE)        \
  39.                      : __va_rounded_size (TYPE))))))
  40.  
  41. #ifndef _VA_LIST_
  42. #define _VA_LIST_
  43. typedef __gnuc_va_list va_list;
  44. #endif /* _VA_LIST_ */
  45.  
  46. #else
  47.  
  48. typedef    __VA_LIST__ va_list;
  49.  
  50. # ifdef __TURBOC__
  51. #  define va_start(list, param)   ((list) = ...)
  52. #  define va_arg(list, type)      (*((type *) (list))++)
  53. #  define va_end(list)
  54. # else
  55. #  define va_start(list,param)  list = ((va_list) &(param)) \
  56.                    + ((sizeof(param) + 1) & ~1)
  57. #  define va_arg(list,type)     ((type *)(list += ((sizeof(type) + 1) & ~1)))[-1]
  58. #  define va_end(list)
  59. # endif /* __TURBOC__ */
  60.  
  61. #endif /* __GNUC__ */
  62.  
  63. #endif /* va_start */
  64.  
  65. #endif /* _STDARG_H */
  66.